/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-13 07:46:40
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-15 22:44:45
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/controller/home_controller.dart';
import 'package:get/get.dart';

import '../../../constants.dart';
import 'menu_item.dart';

class DeviceList extends StatelessWidget {
  const DeviceList({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) => GetBuilder<HomeController>(
      builder: (_controller) => Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.max,
            children: [
              Text(
                "设备",
                style: TextStyle(
                  fontSize: defaultFontSize,
                  color: Color(0xffA1A1A1),
                ),
              ),
              SizedBox(height: 20),
              Container(
                width: double.infinity,
                child: _controller.moduleList.length > 0
                    ? GridView.builder(
                        shrinkWrap: true,
                        physics: NeverScrollableScrollPhysics(),
                        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                          crossAxisCount: 3,
                          crossAxisSpacing: 0,
                          mainAxisSpacing: 0,
                          childAspectRatio: 0.9,
                        ),
                        itemCount: _controller.moduleList.length,
                        itemBuilder: (context, index) => MenuItem(
                          module: _controller.moduleList[index],
                          index: index,
                          color: Theme.of(context).primaryColor,
                        ),
                      )
                    : Center(
                        child: SizedBox(
                          height: 80,
                          width: 80,
                          child: CircularProgressIndicator(),
                        ),
                      ),
              ),
            ],
          ));
}
